// 引入mongoose
const mongoose = require('mongoose');
const moment = require('moment');

// 创建文章集合规则
const Article = mongoose.model('article', new mongoose.Schema({
    title: {
        type: String,
        minlength: 2,
        maxlength: 20,
        required: ['true', '请填写文章标题']
    },
    author: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'User',
        required: ['true', '请传递作者']
    },
    publishDate: {
        type: Date,
        default: Date.now
    },
    cover: {
        type: String,
        default: null
    },
    content: {
        type: String,
        required:true
        // minlength:120
    }
}));


module.exports = {
    Article
    
}